Page({

  data : {
    userInfo : ''
  },

  onLoad() {
    var us = wx.getStorageSync('user')

    this.setData({
      userInfo : us
    })

  },
  getInfo(x) {
    console.log(x);
  },
  login() {
    wx.getUserInfo({
      desc: "必须啊撒的",
      success: res => {

        let user = res.userInfo;
        // 把用户信息存到本地
        wx.setStorageSync('user', user)

        console.log(user);
        this.setData({
          userInfo : user
        })
      },
      fail: res => {
        console.log("授权失败", res);
      }
    })
  },
  loginOut () {
     this.setData ({
        userInfo : ""
     })

     wx.setStorageSync('user', null)

  }


})